package com.swing.dome;

import com.swing.dome.game.GameFrame;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * 饥饿模式:游戏界面
 */
public class Game extends JFrame implements ActionListener {

    private static volatile Game game = new Game();

    private Game() {
    }

    private static Game get() {
        return game;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        System.out.println("处理事件" + System.currentTimeMillis());
    }

    public static void main(String[] args) {
        Timer timer = new Timer(1000, Game.get());
        timer.start();

        try{
            Thread.sleep(5000);
            timer.stop();
        }catch (Exception e){
            // ignore
        }

        Game.get().setVisible(true);
    }
}
